local exclude_fts = {
    'python',
    'javascript',
    'lua',
    'jsx',
    'markdown',
    'cs',--C#
}
--Thanks:coffebar-dotfiles
return {
    "Pocco81/auto-save.nvim",
    config = function()
        require('auto-save').setup({
            execution_message = {
                message = function()
                    return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
                end,
                dim = 0.18,
                cleaning_interval = 1250,
            },
            trigger_events = { "InsertLeave", "TextChanged" },
            -- function that determines whether to save the current buffer or not
            -- return true: if buffer is ok to be saved
            -- return false: if it's not ok to be saved
            condition = function(buf)
                local fn = vim.fn
                local utils = require("auto-save.utils.data")
                local ft = fn.getbufvar(buf, "&filetype")
                local fname = require('utils.buf').get_current_filename()
                if fn.getbufvar(buf, "&modifiable") == 1 and utils.not_in(ft, exclude_fts) then
                    if fname == '' or ft == '' then
                        return false
                    end
                    return true -- met condition(s), can save
                end
                return false -- can't save
            end,
            write_all_buffers = false, -- write all buffers when the current one meets `condition`
            debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
            callbacks = { -- functions to be executed at different intervals
                enabling = nil, -- ran when enabling auto-save
                disabling = nil, -- ran when disabling auto-save
                before_asserting_save = nil, -- ran before checking `condition`
                before_saving = nil,
                after_saving = nil, -- ran after doing the actual save
            },

        })
    end,
}
-- EOP
